﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;

using System.Xml;
using System.Web;
using System.Runtime.InteropServices;
using System.IO.Ports;
using System.IO;

namespace weiqijiance.安检仪表
{
    public partial class TESTZBZL : Form
    {
        public TESTZBZL(int Width, int Height)
        {
            InitializeComponent();
            panel_Width = Width;
            panel_Height = Height;

            x = this.Width;
            y = this.Height;
            setTag(this);
        }

        #region 控件大小随窗体大小等比例缩放
        private float x;//定义当前窗体的宽度
        private float y;//定义当前窗体的高度
        private void setTag(Control cons)
        {
            foreach (Control con in cons.Controls)
            {
                con.Tag = con.Width + ";" + con.Height + ";" + con.Left + ";" + con.Top + ";" + con.Font.Size;
                if (con.Controls.Count > 0)
                {
                    setTag(con);
                }
            }
        }
        private void setControls(float newx, float newy, Control cons)
        {
            //if (newy <= 0)
            //{
            //    newy = 1;
            //}
            //遍历窗体中的控件，重新设置控件的值
            foreach (Control con in cons.Controls)
            {
                //获取控件的Tag属性值，并分割后存储字符串数组
                if (con.Tag != null)
                {
                    string[] mytag = con.Tag.ToString().Split(new char[] { ';' });
                    //根据窗体缩放的比例确定控件的值
                    con.Width = Convert.ToInt32(System.Convert.ToSingle(mytag[0]) * newx);//宽度
                    con.Height = Convert.ToInt32(System.Convert.ToSingle(mytag[1]) * newy);//高度
                    con.Left = Convert.ToInt32(System.Convert.ToSingle(mytag[2]) * newx);//左边距
                    con.Top = Convert.ToInt32(System.Convert.ToSingle(mytag[3]) * newy);//顶边距
                    Single currentSize = System.Convert.ToSingle(mytag[4]) * newy;//字体大小
                    con.Font = new Font(con.Font.Name, currentSize, con.Font.Style, con.Font.Unit);
                    if (con.Controls.Count > 0)
                    {
                        setControls(newx, newy, con);
                    }
                }
            }
        }
        #endregion


        //public mainform m_mainform;
        public int iZBZLDI = -1;//遥控红外
        public string revert = "";
        public float[] fAIDataZero = new float[10] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };//零点漂移值
        public int iZBZLAIz;//整备质量左信号
        public int iZBZLAIy;//整备质量右信号
        public bool[] bhongwaiqf = new bool[16] { false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false };//红外是否取反
        public int[] ihongwaidwsj = new int[16] { 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000 };//红外定位时间单位毫秒

        public float fjcsj;//检测时间
        public int xssj;
      

        public void gettongdao()
        {
            string path = "";
            path = System.Windows.Forms.Application.StartupPath + path + "\\串口及通道设置.ini";
            string path1 = string.Format(@"{0}", path);
            iniclass obj = new iniclass();
            obj.Ini(path1);
            for (int i = 0; i < 10; i++)
            {
                string sgetname = obj.ReadValue("通道设置", string.Format(@"模拟信号{0}", i + 1));
                if (sgetname.Contains("整备质量左"))
                {
                    iZBZLAIz = i;
                }
                if (sgetname.Contains("整备质量右"))
                {
                    iZBZLAIy = i;
                }
            }

            for (int i = 0; i < 16; i++)
            {
                string shongwai = obj.ReadValue("通道设置", string.Format(@"红外{0}", i + 1));
                if (shongwai.Contains("整备质量遥控"))
                {
                    iZBZLDI = i;
                }

                shongwai = obj.ReadValue("通道设置", string.Format(@"红外定位时间{0}", i + 1));
                int.TryParse(shongwai, out ihongwaidwsj[i]);

                shongwai = obj.ReadValue("通道设置", string.Format(@"红外是否取反{0}", i + 1));
                if (shongwai.Contains("是"))
                {
                    bhongwaiqf[i] = true;
                }
                else
                {
                    bhongwaiqf[i] = false;
                }
            }
        }
        string swkcccj = "";
        string sip = "";
        bool bdhzbzl = false;
        bool bdhwkcc = false;
        bool bdb = false;
        bool bfbxs = false;
        public void readshezhitime()
        {


            string path = "";
            path = System.Windows.Forms.Application.StartupPath + path + "\\安综检仪表配置.ini";
            string path1 = string.Format(@"{0}", path);
            iniclass objini = new iniclass();
            objini.Ini(path1);
            xssj = 0;

            float.TryParse(objini.ReadValue("整备质量", "检测时间"), out fjcsj);
            swkcccj = objini.ReadValue("外廓尺寸", "外廓尺寸厂家");

            sip = objini.ReadValue("外廓尺寸", "新成IP地址");

            int.TryParse(objini.ReadValue("检测参数设置", "信息显示时间"), out xssj);

            bdhzbzl = objini.ReadValue("整备质量", "灯牌单行显示") == "是" ? true : false;
            bdhwkcc = objini.ReadValue("外廓尺寸", "灯牌单行显示") == "是" ? true : false;
            bdb = objini.ReadValue("整备质量", "地磅") == "是" ? true : false;
            bfbxs = objini.ReadValue("检测参数设置", "结果采用比例显示") == "是" ? true : false;
            //float.TryParse(objini.ReadValue("检测参数设置", "整备质量信息显示时间"), out xssj);
            if (fjcsj < 10)
            {
                fjcsj = 3000;
            }
            if (xssj < 10)
            {
                xssj = 1000;
            }

        }
        外廓尺寸.wkccbass objwkccbass = new 外廓尺寸.wkccbass();
        private void TESTZBZL_Load(object sender, EventArgs e)
        {
            gettongdao();
            readshezhitime();
            //if(万集)
            if (swkcccj.Contains("万集"))
            {
                objwkccbass = new 外廓尺寸.wkccwanji();
            }
            else if (swkcccj.Contains("新成"))
            {
                objwkccbass = new 外廓尺寸.wkccxincheng(sip);
            }
            
           
            objwkccbass.flowbass = flowbass;
            objwkccbass.objwkcc = this;
        }
        public bool bwkcc = false;
        bool bzbzl = false;
        public bool qdzkzzl = false;
        private void button1_Click(object sender, EventArgs e)
        {
            button1.Enabled = false;
            bqdzkzzl = false;
            qdzkzzl = false;
            if (!flowbass.bJCZBZL)
            {
                sneirongWKCC = "整备质量免检";
                WKCCshow();
                setLedWritezbzl(string.Format("{0}", "整备质量免检"), "整备质量免检", 1);
                MessageBox.Show("整备质量免检");

                sneirongWKCC = "整备质量";
                WKCCshow();
                setLedWritezbzl(string.Format("{0}", "整备质量"), "整备质量", 1);
                button1.Enabled = true;
                return;
            }
            bzbzl = true;
            //StartTestZBZL();
            tzbzl = new Thread(threadzbzl);
            tzbzl.Start();
        }
        void threadzbzl()
        {
            StartTestZBZL();
            sneirongZBZL = "整备质量";
            ZBZLshow();
            setLedWritezbzl(string.Format("{0}", "整备质量"), "", 1);
            flowbass.LedWrite(flowbass.sgongwei, "", 1);
            button1.Enabled = true;
        }

        private void button4_Click(object sender, EventArgs e)
        {
            button1.Enabled = true;
            bzbzl = false;
        }

        private void btnTL_Click(object sender, EventArgs e)
        {
            //if (flowbass.LastProcessnew(int.Parse(flowbass.sDetectID)) && !flowbass.ifinish)
            //{
            //    //flowbass.objajlwbass.sendAJend(flowbass.jylsh, false);
            //    setLedWritezbzl("正在发送", "联网总结束", 1);
            //    string slianwangfanhui = flowbass.objajlwbass.sendAJend(flowbass.jylsh, false);
            //    if (!(slianwangfanhui.Length > 0 && slianwangfanhui[0].ToString() == "1"))
            //    {
            //        setLedWritezbzl("联网失败", slianwangfanhui, 1);
            //    }
            //    else
            //    {
            //        setLedWritezbzl("发送完成", "", 1);
            //    }
            //    Thread.Sleep(2000);
            //}
            m_mainform.DAC.tiaoling(1);
        }
        Thread tjd;

        private void btnJD_Click(object sender, EventArgs e)
        {
            if (btnJD.Text == "开始检定")
            {
                btnJD.Text = "结束检定";
                bjd = true;
                tjd = new Thread(jd);
                tjd.Start();

            }
            else
            {
                btnJD.Text = "开始检定";
                bjd = false;
            }

        }
        public void jd()
        {
            while (true)
            {
                DateTime dstartCYZ = DateTime.Now;
                int icyz = 0;
                double flunzhong1 = 0;
                double flunzhong2 = 0;
                while (true)
                {
                    Thread.Sleep(10);
                    if (m_mainform.DateDiff(DateTime.Now, dstartCYZ) > 100)
                    {
                        break;
                    }
                    if (bdb)
                    {
                        flunzhong1 = m_fAIBrData_ZB + flunzhong1;
                    }
                    else
                    {
                        flunzhong1 = flunzhong1 + m_mainform.DAC.getjsz("整备质量左", m_mainform.DAC.fAIData[iZBZLAIz]) - m_mainform.DAC.getjsz("整备质量左", m_mainform.DAC.fAIDataZero[iZBZLAIz]);
                        flunzhong2 = flunzhong2 + m_mainform.DAC.getjsz("整备质量右", m_mainform.DAC.fAIData[iZBZLAIy]) - m_mainform.DAC.getjsz("整备质量右", m_mainform.DAC.fAIDataZero[iZBZLAIy]);
                    }
                    icyz++;

                }
                flunzhong1 = flunzhong1 / icyz;
                flunzhong2 = flunzhong2 / icyz;
                sneirongL = flunzhong1.ToString("0");
                sneirongR = flunzhong2.ToString("0");
                Lshow();
                Rshow();
                if (bdb)
                {
                    setLedWritezbzl("整备质量", flunzhong1.ToString("0") + "Kg", 1);
                }
                else
                {
                    setLedWritezbzl("左:" + flunzhong1.ToString("0") + "右:" + flunzhong2.ToString("0"), "左:" + flunzhong1.ToString("0") + "右:" + flunzhong2.ToString("0"), 1);
                }
                if (!bjd)
                    break;
            }
            setLedWritezbzl("整备质量", "整备质量", 1);
        }

        Thread twkcc1;
        Thread tzbzl;
        private void button2_Click(object sender, EventArgs e)
        {
            if (!flowbass.bJCWKCC)
            {
                sneirongWKCC = "外廓尺寸免检";
                WKCCshow();
                setLedWritewkcc(string.Format("{0}", "外廓尺寸免检"), "外廓尺寸免检", 1);
                MessageBox.Show("外廓尺寸免检");

                sneirongWKCC = "外廓尺寸";
                WKCCshow();
                setLedWritewkcc(string.Format("{0}", "外廓尺寸"), "外廓尺寸免检", 1);
                return;
            }
            //flowbass.IsReadyForStart();
            if (bwkcc)
            {
                 MessageBox.Show("该车正在检测");
                 return;
            }
            bwkcc = true;
            twkcc1 = new Thread(threadwkcc);
            twkcc1.Start();

        }
        void threadwkcc()
        {
            try
            {
                StartTestWKCC();
                sneirongWKCC = "外廓尺寸";
                WKCCshow();
                setLedWritewkcc(string.Format("{0}", "外廓尺寸"), "外廓尺寸", 1);
                flowbass.LedWrite(flowbass.sgongwei, "", 1);
            }
            catch(Exception ex)
            {
                bwkcc = false;
                MessageBox.Show(ex.ToString());
            }
        }
        private void button3_Click(object sender, EventArgs e)
        {
            bwkcc = false;
        }

        public 控制流程.flowcrtl flowbass = new 控制流程.flowcrtl();
        public string sshebei = "整备质量";
        public mainform m_mainform;
        public string sdetid;

        /// <summary>
        /// 红外信号判断是否到位 路数 是否取反 保持稳定时间
        /// </summary>
        /// <param name="sName"></param>
        public void WaitEvent(int lushu, bool bqufan, int stime)
        {
            DateTime dstart = DateTime.Now;
            bool bzt = false;
            bool firstzt = false;
            while (true)
            {
                if (byksd)
                    return;
                if (flowbass.IsCancle())
                {
                    return;
                }
                bool bzhuangtai = m_mainform.DAC.bDIData[lushu];
                if (bqufan)
                {
                    bzhuangtai = !bzhuangtai;
                }
                if (bzhuangtai)
                {
                    firstzt = true;
                    if (!bzt)
                    {
                        dstart = DateTime.Now;
                    }
                    else
                    {
                        if (DateTime.Now > dstart.AddMilliseconds(stime))
                        {
                            break;
                        }
                        setLedWritezbzl(flowbass.sPlate, "停车", 1);
                    }
                }
                else
                {
                    dstart = DateTime.Now;
                    bzt = true;
                    if (firstzt)
                    {
                        setLedWritezbzl(flowbass.sPlate, "未到位", 1);
                    }
                }
                Thread.Sleep(100);
            }
        }

        public void StartTestZBZL()
        {
            flowbass.objcarclass.tongdao1 = flowbass.izbzlqtongdao.ToString();
            flowbass.objcarclass.tongdao2 = flowbass.izbzlhtongdao.ToString();
            int zlycy = flowbass.m_iycyzl;

            int icount = 0;
            int.TryParse(txtjct.Text, out icount);
            int izbzl = 0;
            if (flowbass.bnj)
            {
                revert = flowbass.objajlwbass.SendJYXMKSSJ("Z1", "开始", flowbass.gwjysbbhzbzl, flowbass.izbzlhtongdao.ToString(), flowbass.objcarclass);
                if (!revert.Contains("1"))
                {
                    setLedWritezbzl("联网失败", revert, 1); Thread.Sleep(2000);
                }
            }
            byksd = false;
            for (int i = 0; i < icount; i++)
            {
                if (!bzbzl)
                    return;
                string sdphx = "第" + (i + 1).ToString() + "组驶上称重台";
                setLedWritezbzl(sdphx, "按遥控开始检测", 1);
                sneirongZBZL = sdphx + "," + "按遥控开始检测";
                ZBZLshow();
                if (!qdzkzzl)
                {
                    flowbass.UpdateLoginRecord(DateTime.Now.ToString(), "整备质量开始", flowbass.sDetectID);
                }
                // 红外定位
                if (flowbass.bnj && icount < 5)
                {
                    flowbass.objajlwbass.sendpic(flowbass.izbzlqtongdao.ToString(), "0362", flowbass.objcarclass);
                }
                // 红外定位
                if (iZBZLDI > -1)//配置红外后才判断红外定位
                {
                    WaitEvent(iZBZLDI, bhongwaiqf[iZBZLDI], ihongwaidwsj[iZBZLDI]);
                }
                byksd = false;
                setLedWritezbzl(sdphx, "正在检测", 1);
                sneirongZBZL = "正在检测";
                ZBZLshow();
                //测量数据
                DateTime dstart = DateTime.Now;
                DateTime dstartCYZ = DateTime.Now;
                int icyz = 0, ilscount = 0;
                float flunzhongZ1 = 0;
                float flunzhongZ2 = 0;
                float flunzhong1 = 0;
                float flunzhong2 = 0;
                while (true)
                {
                    if (!bzbzl)
                        return;
                    Thread.Sleep(10);
                    if (flowbass.IsCancle())
                    {
                        setLedWritezbzl("检测取消", "", 1);
                        return;
                    }
                    if (m_mainform.DateDiff(DateTime.Now, dstart) > fjcsj)
                    {
                        break;
                    }

                    dstartCYZ = DateTime.Now;
                    icyz = 0;
                    flunzhong1 = 0;
                    flunzhong2 = 0;
                    while (true)
                    {
                        Thread.Sleep(10);
                        if (m_mainform.DateDiff(DateTime.Now, dstartCYZ) > 100)
                        {
                            break;
                        }
                        if (bdb)
                        {
                            flunzhong1 = (float)(m_fAIBrData_ZB) + flunzhong1;
                        }
                        else
                        {
                            flunzhong1 = flunzhong1 + m_mainform.DAC.getjsz("整备质量左", m_mainform.DAC.fAIData[iZBZLAIz]) - m_mainform.DAC.getjsz("整备质量左", m_mainform.DAC.fAIDataZero[iZBZLAIz]);
                            flunzhong2 = flunzhong2 + m_mainform.DAC.getjsz("整备质量右", m_mainform.DAC.fAIData[iZBZLAIy]) - m_mainform.DAC.getjsz("整备质量右", m_mainform.DAC.fAIDataZero[iZBZLAIy]);
                        }
                        icyz++;

                    }
                    ilscount++;
                    flunzhongZ1 += flunzhong1 / icyz;
                    flunzhongZ2 += flunzhong2 / icyz;
                    sneirongL = (flunzhong1 / icyz).ToString("0");
                    sneirongR = (flunzhong2 / icyz).ToString("0");
                    Lshow();
                    Rshow();
                }
                if (i < 3)
                {
                    //if (i == 2)
                    //{
                    //    flowbass.objajlwbass.sendpic(flowbass.izbzlqtongdao.ToString(), "0362", flowbass.objcarclass);
                    //    flowbass.objajlwbass.sendpic(flowbass.izbzlhtongdao.ToString(), "0363", flowbass.objcarclass);
                    //}
                    izbzl += (int)Math.Round(flunzhongZ1 / ilscount) + (int)Math.Round(flunzhongZ2 / ilscount);
                }
                else
                {
                    izbzl = izbzl - ((int)Math.Round(flunzhongZ1 / ilscount) + (int)Math.Round(flunzhongZ2 / ilscount));
                }
                sneirongL = ((int)Math.Round(flunzhongZ1 / ilscount)).ToString("0");
                sneirongR = ((int)Math.Round(flunzhongZ2 / ilscount)).ToString("0");
                Lshow();
                Rshow();
            }

            if (icount < 3)//减去引车员重量及尾板质量
            {
                izbzl = izbzl - zlycy - flowbass.wbzl;
            }

            setLedWritezbzl("整备质量", izbzl.ToString(), 1);
            sneirongZBZL = izbzl.ToString();
            ZBZLshow();
            Thread.Sleep(xssj);


            string szbzlxz = "";
            int iblsxz = 0;
            int iblxxz = 0;
            int iczsxz = 0;
            int iczxxz = 0;
            int izbzlsx = 0;
            int izbzlxx = 0;
            if (flowbass.sjcbz.Contains("38900"))
            {
                if (flowbass.sxcrh.Contains("注册")  || flowbass.sxcrh.Contains("过户") || flowbass.sxcrh.Contains("新车"))//2019-801A过户使用注册登记限值
                {
                    if (!bqdzkzzl)
                    {
                        updatezbzlpanding(izbzl, ref  szbzlxz, ref  iblsxz, ref  iblxxz, ref  iczsxz, ref  iczxxz, ref  izbzlsx, ref  izbzlxx);
                        pandingzbzl(izbzl, szbzlxz, iblsxz, iblxxz, iczsxz, iczxxz, izbzlsx, izbzlxx, 0);
                    }
                }
                else
                {
                    if (!bqdzkzzl)
                    {
                        updatezbzlpanding_kczl(izbzl, ref  szbzlxz, ref  iblsxz, ref  iblxxz, ref  iczsxz, ref  iczxxz, ref  izbzlsx, ref  izbzlxx);
                        pandingzbzl(izbzl, szbzlxz, iblsxz, iblxxz, iczsxz, iczxxz, izbzlsx, izbzlxx, 1);
                    }
                }
            }
            else
            {
                if (!bqdzkzzl)
                {
                    updatezbzlpanding(izbzl, ref  szbzlxz, ref  iblsxz, ref  iblxxz, ref  iczsxz, ref  iczxxz, ref  izbzlsx, ref  izbzlxx);
                    pandingzbzl(izbzl, szbzlxz, iblsxz, iblxxz, iczsxz, iczxxz, izbzlsx, izbzlxx, 0);
                }
            }
            bqdzkzzl = false;
            flowbass.AddData_Check(flowbass.sDetectID, "DET_ZBZL", "Detects_SJA", izbzl.ToString("0"));
            if (flowbass.bnj)
            {
                //if (icount < 5)
                //{
                //    flowbass.objajlwbass.sendpic(flowbass.izbzlhtongdao.ToString(), "0363", flowbass.objcarclass);
                //}
                if (flowbass.LastProcessnew(int.Parse(flowbass.sDetectID)) && !flowbass.ifinish)
                {
                    setLedWritezbzl("正在发送", "联网  总结束", 1);
                    string slianwangfanhui = flowbass.objajlwbass.sendAJend(flowbass.jylsh, false, flowbass.bzj);
                    if (!(slianwangfanhui.Length > 0 && slianwangfanhui[0].ToString() == "1"))
                    {
                        setLedWritezbzl("联网失败", slianwangfanhui, 1);
                    }
                    else
                    {
                        setLedWritezbzl("发送完成", "发送完成", 1);
                        flowbass.UpdateLoginRecord(DateTime.Now.ToString(), "检测线完成", flowbass.sDetectID);
                    }
                    Thread.Sleep(2000);
                }
            }
            flowbass.Updatejcxhao(flowbass.objcarclass.jcxdh, flowbass.sDetectID);

        }

        //-------------------------------------------------------------
        string sneirongZBZL = "";
        public string sneirongWKCC = "";
        string sneirongL = "";
        string sneirongR = "";
        string sneirongC = "";
        string sneirongK = "";
        string sneirongG = "";
        private delegate void FlushClient();//代理
        public void ZBZLshow()
        {
            if (this.xianshiZBZL.InvokeRequired)//等待异步
            {
                FlushClient fc = new FlushClient(ZBZLshow);
                this.Invoke(fc);//通过代理调用刷新方法
            }
            else
            {
                this.xianshiZBZL.Text = string.Format(@"{0}", sneirongZBZL);
            }
        }
        public void WKCCshow()
        {
            if (this.xianshiWKCC.InvokeRequired)//等待异步
            {
                FlushClient fc = new FlushClient(WKCCshow);
                this.Invoke(fc);//通过代理调用刷新方法
            }
            else
            {
                this.xianshiWKCC.Text = string.Format(@"{0}", sneirongWKCC);
            }
        }
        //-----------------------------
        public void Lshow()
        {
            if (this.gauge_weight_left.InvokeRequired)//等待异步
            {
                FlushClient fc = new FlushClient(Lshow);
                this.Invoke(fc);//通过代理调用刷新方法
            }
            else
            {
                this.gauge_weight_left.Visible = true;
                this.digitalGauge1.DigitCount = sneirongL.Length < 3 ? 3 : sneirongL.Length;
                this.digitalGauge1.Text = sneirongL;
            }
        }
        public void Rshow()
        {
            if (this.gauge_weight_right.InvokeRequired)//等待异步
            {
                FlushClient fc = new FlushClient(Rshow);
                this.Invoke(fc);//通过代理调用刷新方法
            }
            else
            {
                this.gauge_weight_right.Visible = true;
                this.digitalGauge2.DigitCount = sneirongR.Length < 3 ? 3 : sneirongR.Length;
                this.digitalGauge2.Text = sneirongR;
            }
        }
        public void Cshow()
        {
            if (this.gauge_chang.InvokeRequired)//等待异步
            {
                FlushClient fc = new FlushClient(Cshow);
                this.Invoke(fc);//通过代理调用刷新方法
            }
            else
            {
                this.gauge_chang.Visible = true;
                this.digitalGauge3.DigitCount = string.Format(@"{0}", sneirongC).Length < 3 ? 3 : string.Format(@"{0}", sneirongC).Length;
                this.digitalGauge3.Text = string.Format(@"{0}", sneirongC);
               // this.txtC.Text = string.Format(@"{0}", sneirongC);
            }
        }
        public void Kshow()
        {
            if (this.gauge_kuan.InvokeRequired)//等待异步
            {
                FlushClient fc = new FlushClient(Kshow);
                this.Invoke(fc);//通过代理调用刷新方法
            }
            else
            {
                this.gauge_kuan.Visible = true;
                this.digitalGauge4.DigitCount = string.Format(@"{0}", sneirongK).Length < 3 ? 3 : string.Format(@"{0}", sneirongK).Length;
                this.digitalGauge4.Text = string.Format(@"{0}", sneirongK);
                //this.txtK.Text = string.Format(@"{0}", sneirongK);
            }
        }
        public void Gshow()
        {
            if (this.gauge_gao.InvokeRequired)//等待异步
            {
                FlushClient fc = new FlushClient(Gshow);
                this.Invoke(fc);//通过代理调用刷新方法
            }
            else
            {
                this.gauge_gao.Visible = true;
                this.digitalGauge5.DigitCount = string.Format(@"{0}", sneirongG).Length < 3 ? 3 : string.Format(@"{0}", sneirongG).Length;
                this.digitalGauge5.Text = string.Format(@"{0}", sneirongG);
               // this.txtG.Text = string.Format(@"{0}", sneirongG);
            }
        }
        bool bjd = false;

        private void timer2_Tick(object sender, EventArgs e)
        {

            try
            {
                m_mainform.sethongwai(lblhongwai1, m_mainform.WaitEventZT(iZBZLDI, bhongwaiqf[iZBZLDI], ihongwaidwsj[iZBZLDI]));
            }
            catch
            { }
        }

        void getstandwkcc(ref int icsx,ref int icxx,ref int iksx,ref int ikxx,ref int igsx,ref int igxx)
        {
            string scllx = flowbass.sCllx;
            string sxcrh = flowbass.sxcrh;
            int ichang = flowbass.ichang;
            int ikuan = flowbass.ikuan;
            int igao = flowbass.igao;
            int iVax = flowbass.iVax;
            int izzl = flowbass.iCLZZL;
            int ichangmax = 0;
            int ikuanmax = 0;
            int igaomax = 0;
            if (scllx.Contains("客") || scllx.Contains("轿") || scllx.Contains("面包"))
            {
                ichangmax = 12000;
                ikuanmax = 2550;
                igaomax = 4000;
            }
            else if (scllx.Contains("低速"))
            {
                ichangmax = 6000;
                ikuanmax = 2000;
                igaomax = 2500;
            }
            else
            {
                ichangmax = 12000;
                ikuanmax = 2550;
                igaomax = 4000;
                if (scllx.Contains("半挂车") && (scllx.Contains("仓栅") || scllx.Contains("平板") || scllx.Contains("栏板") || scllx.Contains("自卸")))
                {
                    if (iVax == 3)
                    {
                        ichangmax = 13000;
                    }
                    else if (iVax == 2)
                    {
                        ichangmax = 10000;
                    }
                    else
                    {
                        ichangmax = 8600;
                    }
                }
                else if (scllx.Contains("货") && (scllx.Contains("仓栅") || scllx.Contains("平板") || scllx.Contains("栏板") || scllx.Contains("自卸")))
                {

                    if (iVax == 4)
                    {
                        ichangmax = 12000;
                    }
                    else if (iVax == 3)
                    {
                        if (izzl > 20000)
                        {
                            ichangmax = 12000;
                        }
                        else
                        {
                            ichangmax = 11000;
                        }

                    }
                    else if (iVax == 2)
                    {
                        if (izzl > 12000)
                        {
                            ichangmax = 9000;
                        }
                        else if (izzl > 8000 && izzl < 12001)
                        {
                            ichangmax = 8000;
                        }
                        else if (izzl > 3500 && izzl < 8001)
                        {
                            ichangmax = 7000;
                        }
                        else
                        {
                            ichangmax = 6000;
                        }
                    }
                    else
                    {
                        ichangmax = 6000;
                    }
                }
                //else if (scllx.Contains("专项"))
                //{
                //    ichangmax = 999999;
                //}
                else
                {
                    //ichangmax = 999999;
                }
            }
            if (sxcrh.Contains("注册") || sxcrh.Contains("新车") || flowbass.sxcrh.Contains("过户"))//2019-801A过户使用注册登记限值
            {
                icsx = ichang + getjs(ichang, 1, 50);
                icxx = ichang - getjs(ichang, 1, 50);

                iksx = ikuan + getjs(ikuan, 1, 50);
                ikxx = ikuan - getjs(ikuan, 1, 50);

                igsx = igao + getjs(igao, 1, 50);
                igxx = igao - getjs(igao, 1, 50);
            }
            else
            {
                icsx = ichang + getjs(ichang, 2, 100);
                icxx = ichang - getjs(ichang, 2, 100);

                iksx = ikuan + getjs(ikuan, 2, 100);
                ikxx = ikuan - getjs(ikuan, 2, 100);

                igsx = igao + getjs(igao, 2, 100);
                igxx = igao - getjs(igao, 2, 100);
            }
            if (ichangmax < ichang)
            {
                ichangmax = 999999;
            }
            if (ikuanmax < ikuan)
            {
                ikuanmax = 999999;
            }
            if (igaomax < igao)
            {
                igaomax = 999999;
            }

            if (icsx > ichangmax)
            {
                icsx = ichangmax;
            }
            if (iksx > ikuanmax)
            {
                iksx = ikuanmax;
            }
            if (igsx > igaomax)
            {
                igsx = igaomax;
            }
        }

        void getstandwkcc_38900(ref int icsx, ref int icxx, ref int iksx, ref int ikxx, ref int igsx, ref int igxx)
        {
            string scllx = flowbass.sCllx;
            string sxcrh = flowbass.sxcrh;
            int ichang = flowbass.ichang;
            int ikuan = flowbass.ikuan;
            int igao = flowbass.igao;
            int iVax = flowbass.iVax;
            int izzl = flowbass.iCLZZL;
            int ichangmax = 0;
            int ikuanmax = 0;
            int igaomax = 0;
            if (scllx.Contains("客") || scllx.Contains("轿") || scllx.Contains("面包"))
            {
                ichangmax = 12000;
                ikuanmax = 2550;
                igaomax = 4000;
            }
            else if (scllx.Contains("低速"))
            {
                ichangmax = 6000;
                ikuanmax = 2000;
                igaomax = 2500;
            }
            else
            {
                ichangmax = 12000;
                ikuanmax = 2550;
                igaomax = 4000;
                if (scllx.Contains("半挂车") && (scllx.Contains("仓栅") || scllx.Contains("平板") || scllx.Contains("栏板") || scllx.Contains("自卸")))
                {
                    if (iVax == 3)
                    {
                        ichangmax = 13000;
                    }
                    else if (iVax == 2)
                    {
                        ichangmax = 10000;
                    }
                    else
                    {
                        ichangmax = 8600;
                    }
                }
                else if (scllx.Contains("货") && (scllx.Contains("仓栅") || scllx.Contains("平板") || scllx.Contains("栏板") || scllx.Contains("自卸")))
                {

                    if (iVax == 4)
                    {
                        ichangmax = 12000;
                    }
                    else if (iVax == 3)
                    {
                        if (izzl > 20000)
                        {
                            ichangmax = 12000;
                        }
                        else
                        {
                            ichangmax = 11000;
                        }

                    }
                    else if (iVax == 2)
                    {
                        if (izzl > 12000)
                        {
                            ichangmax = 9000;
                        }
                        else if (izzl > 8000 && izzl < 12001)
                        {
                            ichangmax = 8000;
                        }
                        else if (izzl > 3500 && izzl < 8001)
                        {
                            ichangmax = 7000;
                        }
                        else
                        {
                            ichangmax = 6000;
                        }
                    }
                    else
                    {
                        ichangmax = 6000;
                    }
                }
                //else if (scllx.Contains("专项"))
                //{
                //    ichangmax = 999999;
                //}
                else
                {
                    //ichangmax = 999999;
                }
            }
            if (sxcrh.Contains("注册") || sxcrh.Contains("新车") || flowbass.sxcrh.Contains("过户"))//2019-801A过户使用注册登记限值
            {
                if (scllx.Contains("摩托") || scllx.Contains("三轮汽车"))
                {
                    icsx = ichang + getjs(ichang, 3, 50);
                    icxx = ichang - getjs(ichang, 3, 50);

                    iksx = ikuan + getjs(ikuan, 3, 50);
                    ikxx = ikuan - getjs(ikuan, 3, 50);

                    igsx = igao + getjs(igao, 3, 50);
                    igxx = igao - getjs(igao, 3, 50);

                }
                else
                {
                    icsx = ichang + getjs(ichang, 1, 50);
                    icxx = ichang - getjs(ichang, 1, 50);

                    iksx = ikuan + getjs(ikuan, 1, 50);
                    ikxx = ikuan - getjs(ikuan, 1, 50);

                    igsx = igao + getjs(igao, 1, 50);
                    igxx = igao - getjs(igao, 1, 50);
                }
            }
            else
            {
                icsx = ichang + getjs(ichang, 3, 150);
                icxx = ichang - getjs(ichang, 3, 150);

                iksx = ikuan + getjs(ikuan, 3, 150);
                ikxx = ikuan - getjs(ikuan, 3, 150);

                igsx = igao + getjs(igao, 3, 150);
                igxx = igao - getjs(igao, 3, 150);
            }
            if (ichangmax < ichang)
            {
                ichangmax = 999999;
            }
            if (ikuanmax < ikuan)
            {
                ikuanmax = 999999;
            }
            if (igaomax < igao)
            {
                igaomax = 999999;
            }

            if (icsx > ichangmax)
            {
                icsx = ichangmax;
            }
            if (iksx > ikuanmax)
            {
                iksx = ikuanmax;
            }
            if (igsx > igaomax)
            {
                igsx = igaomax;
            }
        }
        int getjs(int iwk,int ibl,int imm)
        {
            int ireturn = (int)Math.Max(((double)iwk) * ((double)ibl) / 100, imm);
            return ireturn;
        }
        public void StartTestWKCC()
        {
            flowbass.objcarclass.tongdao1 = flowbass.iwkccqtongdao.ToString();
            flowbass.objcarclass.tongdao2 = flowbass.iwkccthongdao.ToString();
            //发送车辆信息
            int iwkcsx = 0;
            int iwkcxx = 0;
            int iwkksx = 0;
            int iwkkxx = 0;
            int iwkgsx = 0;
            int iwkgxx = 0;
            if (flowbass.sjcbz.Contains("38900"))
            {
                getstandwkcc_38900(ref iwkcsx, ref iwkcxx, ref iwkksx, ref iwkkxx, ref iwkgsx, ref iwkgxx);
            }
            else
            {
                getstandwkcc(ref iwkcsx, ref iwkcxx, ref iwkksx, ref iwkkxx, ref iwkgsx, ref iwkgxx);
            }
            string lengthxz;
            string widthxz;
            string heightxz;
            //int ichang = flowbass.ichang;
            //int ikuan = flowbass.ikuan;
            //int igao = flowbass.igao;
            lengthxz = string.Format(@"{0}", iwkcsx);
            widthxz = string.Format(@"{0}", iwkksx);
            heightxz = string.Format(@"{0}", iwkgsx);
            if (flowbass.bnj)
            {
                revert = flowbass.objajlwbass.SendJYXMKSSJ("M1", "开始", flowbass.gwjysbbhwkcc, flowbass.iwkccqtongdao.ToString(), flowbass.objcarclass);
                if (!(revert.Length > 0 && revert[0].ToString() == "1"))
                {
                    setLedWritewkcc("联网失败", revert, 1); Thread.Sleep(2000);
                }
                if (!flowbass.lwpt.Contains("睿擎"))
                {
                    flowbass.objajlwbass.sendpic(flowbass.iwkccqtongdao.ToString(), "0360", flowbass.objcarclass);
                }
            }


            //string result = "";
            //string info = "";
            //  ShowMsg("loginVehicle(......)");

            setLedWritewkcc(flowbass.sPlate, "缓慢驶入外廓区域", 1);
            sneirongWKCC = "缓慢驶入外廓区域";
            WKCCshow();

            int length = 0;
            int width = 0;
            int height = 0;

            //人工复检数据
            int length_artificial=0;
            int width_artificial=0;
            int height_artificial=0;
            int artificial = 0;

            objwkccbass.getliucheng_artificial(lengthxz, widthxz, heightxz, ref length, ref width, ref height, ref length_artificial, ref width_artificial, ref height_artificial, ref artificial);

            //-------------------------万集
            #region 万集的，取消使用多态
            // string path = "";
            // path = System.Windows.Forms.Application.StartupPath + path + "\\安综检仪表配置.ini";
            // string path1 = string.Format(@"{0}", path);
            // iniclass objini = new iniclass();
            // objini.Ini(path1);
            // string swenjianlujing = objini.ReadValue("外廓尺寸", "文件路径");

            // //   MessageBox.Show(swenjianlujing);

            // string sguache = "否";
            // string sjcbf = "头";
            // if (flowbass.sPclass.Contains("15") || flowbass.sPclass.Contains("挂"))
            // {
            //     sguache = "是";
            //     sjcbf = "挂";
            // }



            // objini.Ini(string.Format(@"{0}TestCmd.ini", swenjianlujing));
            // objini.Writue("检测信息", "是否挂车", sguache);
            // objini.Writue("检测信息", "检测部分", sjcbf);
            // objini.Writue("检测信息", "是否检测整备质量", "否");
            // objini.Writue("检测信息", "是否检测栏板高度", "否");

            // objini.Writue("车体部分1", "检验流水号",flowbass.jylsh);
            // objini.Writue("车体部分1", "车牌号码", flowbass.sPlate);
            // objini.Writue("车体部分1", "号牌种类", flowbass.sPclass);
            // objini.Writue("车体部分1", "车辆类型", flowbass.sCllx);
            // objini.Writue("车体部分1", "车身颜色", flowbass.scsys);
            // objini.Writue("车体部分1", "车主单位", flowbass.owner);
            // objini.Writue("车体部分1", "底盘号码", flowbass.svin);
            // objini.Writue("车体部分1", "检验类别", flowbass.sxcrh);
            // objini.Writue("车体部分1", "出厂日期", flowbass.dCCRQ.ToString("yyyy-MM-dd"));
            // objini.Writue("车体部分1", "检测线号", "1");
            // objini.Writue("车体部分1", "检测次数", flowbass.iITERAT.ToString());
            // objini.Writue("车体部分1", "车轴数", string.Format(@"{0}", flowbass.iVax));
            // objini.Writue("车体部分1", "出厂长", flowbass.ichang.ToString());
            // objini.Writue("车体部分1", "出厂宽", flowbass.ikuan.ToString());
            // objini.Writue("车体部分1", "出厂高", flowbass.igao.ToString());
            // objini.Writue("车体部分1", "长度上限值", lengthxz);
            // objini.Writue("车体部分1", "宽度上限值", widthxz);
            // objini.Writue("车体部分1", "高度上限值", heightxz);
            // objini.Writue("车体部分1", "栏板高度", "400");
            // objini.Writue("车体部分1", "轴距", flowbass.szhouju);
            // objini.Writue("车体部分1", "出厂质量", string.Format(@"{0}", flowbass.iCLZBZL));




            // objini.Writue("车体部分2", "检验流水号", "21070116092100048");
            // objini.Writue("车体部分2", "车牌号码", "晋00001");
            // objini.Writue("车体部分2", "号牌种类", "大型汽车");
            // objini.Writue("车体部分2", "车辆类型", "大型专项作业车");
            // objini.Writue("车体部分2", "车身颜色", "蓝色");
            // objini.Writue("车体部分2", "车主单位", "个人");
            // objini.Writue("车体部分2", "底盘号码", "LWXSSJDJSKAS1232SD");
            // objini.Writue("车体部分2", "检验类别", "01");
            // objini.Writue("车体部分2", "出厂日期", "2016/04/12");
            // objini.Writue("车体部分2", "检测线号", "1");
            // objini.Writue("车体部分2", "检测次数", "1");
            // objini.Writue("车体部分2", "车轴数", "2");
            // objini.Writue("车体部分2", "出厂长", "7900");
            // objini.Writue("车体部分2", "出厂宽", "2500");
            // objini.Writue("车体部分2", "出厂高", "3200");
            // objini.Writue("车体部分2", "栏板高度", "400");
            // objini.Writue("车体部分2", "轴距", "4500");
            // objini.Writue("车体部分2", "出厂质量", "4200");



            // //开始测量
            // //测量状态

            // //结果 变量参数
            // result = "";
            // info = "";
            // int length = 0;
            // int width = 0;
            //int height = 0;

            // string lengthJudge = "";
            // string heightJudge = "";
            // string widthJudge = "";
            // string zhouju = "";
            // string zhoujuPD = "";
            // string zhoujuXZ = "";
            // string danbangaodu = "";
            // string danbangaoduPD = "";
            // string danbangaoduXZ = "";


            // string sdenpaixianshi = "";
            // string smubiaolujin = string.Format("{0}", swenjianlujing);

            // string SPIDWK = "";// luxiangkais(idetid, "18X61", "1", "M1", "150213060048044803");

            // // MessageBox.Show("测试开始");
            // string fullname = "";

            // for (; ; )
            // {


            //     if (!bwkcc)
            //     {
            //         sneirongWKCC = "外廓尺寸";
            //         WKCCshow();
            //         setLedWritezbzl(string.Format("{0}", "外廓尺寸"), "", 1);
            //         return;
            //     }
            //     bool bbz = false;
            //     //break;
            //     //fullname = addSubDirectory(new DirectoryInfo(smubiaolujin), "*.ini");//
            //     foreach (FileInfo fi in (new DirectoryInfo(smubiaolujin)).GetFiles("*.ini"))
            //     {
            //         fullname = fi.FullName;

            //         //过程信息
            //         if (fullname.IndexOf("TestProc.ini") > -1)//
            //         {
            //            objini.Ini(fullname);
            //            sdenpaixianshi = objini.ReadValue("过程信息", "显示信息");
            //            if (objini.ReadValue("过程信息", "抓拍信息").Contains("车头"))
            //             {
            //                 //sendpic(idetid, "9999", swkccq, "0360", "08");
            //                 ////SendMessageEXX(idetid, "M1", "0360", "150213060048044803");
            //                 //// sendpic(idetid, "9999", swkcch, "0361", "07");
            //             }
            //            else if (objini.ReadValue("过程信息", "抓拍信息").Contains("车尾"))
            //             {
            //                 //sendpic(idetid, "9999", swkcch, "0361", "08");
            //                 ////SendMessageEXX(idetid, "M1", "0361", "150213060048044802");
            //             }
            //             File.Delete(fullname);//删除文件 显示提示
            //             if (sdenpaixianshi != "")
            //             {
            //                 if (sdenpaixianshi.Length < 17)
            //                 {
            //                     //setLedWritezbzl(flowbass.sPlate, "缓慢驶入外廓区域", 1);
            //                     sneirongWKCC = sdenpaixianshi;
            //                     WKCCshow();
            //                     setLedWritezbzl(sdenpaixianshi, "", 1);
            //                 }
            //             }

            //         }
            //         //结果
            //         if (fullname.IndexOf("TestResult.ini") > -1)//得到结果退出检测
            //         {
            //             objini.Ini(fullname);
            //             if (objini.ReadValue("结果", "检测结果数").Contains("1"))
            //             {
            //                 int.TryParse(objini.ReadValue("车体结果1", "长"), out length);
            //                 int.TryParse(objini.ReadValue("车体结果1", "宽"), out width);
            //                 int.TryParse(objini.ReadValue("车体结果1", "高"), out height);

            //                 lengthJudge = objini.ReadValue("车体结果1", "长判定");
            //                 widthJudge = objini.ReadValue("车体结果1", "宽判定");
            //                 heightJudge = objini.ReadValue("车体结果1", "高判定");

            //                 danbangaodu = objini.ReadValue("车体结果1", "栏板高度");
            //                 danbangaoduPD = objini.ReadValue("车体结果1", "栏板高度判定");
            //                 danbangaoduXZ = objini.ReadValue("车体结果1", "栏板高度标准");
            //             }
            //             else
            //             {
            //                 int.TryParse(objini.ReadValue("车体结果2", "长"), out length);
            //                 int.TryParse(objini.ReadValue("车体结果2", "宽"), out width);
            //                 int.TryParse(objini.ReadValue("车体结果2", "高"), out height);

            //                 lengthJudge = objini.ReadValue("车体结果2", "长判定");
            //                 widthJudge = objini.ReadValue("车体结果2", "宽判定");
            //                 heightJudge = objini.ReadValue("车体结果2", "高判定");

            //                 danbangaodu = objini.ReadValue("车体结果2", "栏板高度");
            //                 danbangaoduPD = objini.ReadValue("车体结果2", "栏板高度判定");
            //                 danbangaoduXZ = objini.ReadValue("车体结果2", "栏板高度标准");
            //             }
            //             System.Threading.Thread.Sleep(500);
            //             bbz = true;
            //             File.Delete(fullname);
            //             break;
            //         }

            //     }
            //     if (bbz)
            //         break;
            //     //测量过程
            //     System.Threading.Thread.Sleep(1000);
            // }
            #endregion
            //---------------------------------------------------------------万集结束
            string sjieguodp = string.Format("长:{0}宽:{1}高:{2}", length, width, height);
            sneirongWKCC = sjieguodp;
            WKCCshow();
            ////setLedWritewkcc(string.Format("长:{0}", length), string.Format("长:{0}", length), 1);
            //setLedWritewkcc("长", string.Format("{0}", length), 1);
            //System.Threading.Thread.Sleep(xssj);
            ////setLedWritewkcc(string.Format("宽:{0}", width), string.Format("宽:{0}", width), 1);
            //setLedWritewkcc("宽", string.Format("{0}", width), 1);
            //System.Threading.Thread.Sleep(xssj);
            ////setLedWritewkcc(string.Format("高:{0}", height), string.Format("高:{0}", height), 1);
            //setLedWritewkcc("高", string.Format("{0}", height), 1);
            //System.Threading.Thread.Sleep(xssj);
            setLedWritewkcc(string.Format("{0}x{1}x{2}", length, width, height), "", 1);
            System.Threading.Thread.Sleep(xssj);
            sneirongC = length.ToString();
            sneirongK = width.ToString();
            sneirongG = height.ToString();
            Cshow();
            Kshow();
            Gshow();

            //
            //结果存储
            flowbass.AddData_Check(flowbass.sDetectID, "DET_WKCCC", "Detects_SJA", length.ToString("0"));
            flowbass.AddData_Check(flowbass.sDetectID, "DET_WKCCK", "Detects_SJA", width.ToString("0"));
            flowbass.AddData_Check(flowbass.sDetectID, "DET_WKCCG", "Detects_SJA", height.ToString("0"));

            if (flowbass.sjcbz.Contains("38900"))
            {
                flowbass.AddData_Check(flowbass.sDetectID, "DET_WKCCC_RGFJ", "Detects_SJA", length_artificial.ToString("0"));
                flowbass.AddData_Check(flowbass.sDetectID, "DET_WKCCK_RGFJ", "Detects_SJA", width_artificial.ToString("0"));
                flowbass.AddData_Check(flowbass.sDetectID, "DET_WKCCG_RGFJ", "Detects_SJA", height_artificial.ToString("0"));
                flowbass.AddData_Check(flowbass.sDetectID, "DET_WKCC_RGFJ", "Detects_SJA", artificial.ToString("0"));
            }
           

            if (artificial>0)//人工复检，采用人工复检数据
            {
                length=length_artificial;
                width = width_artificial;
                height = height_artificial;
            }

            {
                int icpd = 1, ikpd = 1, igpd = 1;
                if (length > iwkcsx || length < iwkcxx)
                {
                    icpd = 2;
                }

                if (width > iwkksx || width < iwkkxx)
                {
                    ikpd = 2;
                }

                if (height > iwkgsx || height < iwkgxx)
                {
                    igpd = 2;
                }

                string spd = "合格";
                string swkccpd = "1";
                if (icpd == 2 || ikpd == 2 || igpd == 2)
                {
                    swkccpd = "2";
                    spd = "不合格";
                    flowbass.getbuhge(flowbass.sDetectID, "M1");
                }
                else
                {
                    flowbass.sethege(flowbass.sDetectID, "M1");
                }

                sneirongWKCC = spd;
                WKCCshow();
                //setLedWritewkcc(string.Format("{0}", spd), string.Format("{0}", spd), 1);
                setLedWritewkcc(spd,"", 1);
                System.Threading.Thread.Sleep(xssj);

                string swkcc = string.Format("{0}×{1}×{2}", length, width, height);
                string szbzlxz1 = string.Format("{0}～{1}", iwkcxx, iwkcsx);
                string szbzlxz2 = string.Format("{0}～{1}", iwkkxx, iwkksx);
                string szbzlxz3 = string.Format("{0}～{1}", iwkgxx, iwkgsx);
                string swkccjieguo = "";
               
                if (bfbxs)
                {
                    if (flowbass.sjcbz.Contains("38900"))
                    {
                        if (flowbass.sxcrh.Contains("注册") || flowbass.sxcrh.Contains("过户") || flowbass.sxcrh.Contains("新车"))//2019-801A过户使用注册登记限值
                        {
                            swkccjieguo = string.Format("外廓尺寸(mm),{0},{1},{2}", swkcc, "±1％或±50mm", spd);
                        }
                        else
                        {
                            swkccjieguo = string.Format("外廓尺寸(mm),{0},{1},{2}", swkcc, "±3％或±150mm", spd);
                        }
                    }
                    else
                    {
                        if (flowbass.sxcrh.Contains("注册") || flowbass.sxcrh.Contains("过户"))//2019-801A过户使用注册登记限值
                        {
                            swkccjieguo = string.Format("外廓尺寸(mm),{0},{1},{2}", swkcc, "±1％或±50mm", spd);
                        }
                        else
                        {
                            swkccjieguo = string.Format("外廓尺寸(mm),{0},{1},{2}", swkcc, "±2％或±100mm", spd);
                        }
                    }
                  
                }
                else
                {
                    swkccjieguo = string.Format("外廓尺寸(mm),{0},({1})/({2})/({3}),{4}", swkcc, szbzlxz1, szbzlxz2, szbzlxz3, spd);
                }            
                flowbass.AddData(flowbass.sDetectID, "PD_WKCC", "PD_AJ", swkccjieguo);

                flowbass.AddData(flowbass.sDetectID, "DET_WKCCJL", "Detects_SJA", swkccpd);

               
                flowbass.AddData(flowbass.sDetectID, "DET_WKCJL", "Detects_SJA", icpd.ToString("0"));
                flowbass.AddData(flowbass.sDetectID, "DET_WKKJL", "Detects_SJA", ikpd.ToString("0"));
                flowbass.AddData(flowbass.sDetectID, "DET_WKGJL", "Detects_SJA", igpd.ToString("0"));

                if (flowbass.bnj)
                {
                    if (flowbass.lwpt.Contains("睿擎"))
                    {
                        flowbass.objajlwbass.sendpic(flowbass.iwkccqtongdao.ToString(), "0360", flowbass.objcarclass);
                    }
                    flowbass.objajlwbass.sendpic(flowbass.iwkccthongdao.ToString(), "0361", flowbass.objcarclass);

                    model.安检联网.modelM1 objass = new model.安检联网.modelM1();
                    objass.cwkc = length.ToString();
                    objass.cwkg = height.ToString();
                    objass.cwkk = width.ToString();
                    objass.clwkccpd = swkccpd;
                    objass.sfjsb = "";
                    objass.cwkcrgfc = "";
                    objass.cwkkrgfc = "";
                    objass.cwkgrgfc = "";
                    revert = flowbass.objajlwbass.write(flowbass.objcarclass, objass);
                    if (!(revert.Length > 0 && revert[0].ToString() == "1"))
                    {
                        setLedWritewkcc("联网失败", revert, 1); Thread.Sleep(2000);
                    }


                    flowbass.getProcessfinish(flowbass.sDetectID, "M1");
                    revert = flowbass.objajlwbass.SendJYXMKSSJ("M1", "结束", flowbass.gwjysbbhwkcc, flowbass.iwkccqtongdao.ToString(), flowbass.objcarclass);

                    if (!(revert.Length > 0 && revert[0].ToString() == "1"))
                    {
                        setLedWritewkcc("联网失败", revert, 1); Thread.Sleep(2000);
                    }
                    flowbass.UpdateLoginRecord(DateTime.Now.ToString(), "外廓尺寸结束", flowbass.sDetectID);
                    sneirongWKCC = "外廓尺寸";
                    WKCCshow();
                    if (flowbass.LastProcessnew(int.Parse(flowbass.sDetectID)) && !flowbass.ifinish)
                    {
                        //flowbass.objajlwbass.sendAJend(flowbass.jylsh, false);
                        setLedWritewkcc("正在发送", "联网总结束", 1);
                        string slianwangfanhui = flowbass.objajlwbass.sendAJend(flowbass.jylsh, false, flowbass.bzj);
                        if (!(slianwangfanhui.Length > 0 && slianwangfanhui[0].ToString() == "1"))
                        {
                            setLedWritewkcc("联网失败", slianwangfanhui, 1);
                        }
                        else
                        {
                            setLedWritewkcc("发送完成", "发送完成", 1);
                            flowbass.UpdateLoginRecord(DateTime.Now.ToString(), "检测线完成", flowbass.sDetectID);
                        }
                        Thread.Sleep(2000);
                    }
                }
                bwkcc = false;
                flowbass.Updatejcxhao(flowbass.objcarclass.jcxdh, flowbass.sDetectID);
                setLedWritewkcc(string.Format("{0}", "外廓尺寸"), string.Format("{0}", "外廓尺寸"), 1);
            }
        }
        public int panel_Width;
        public int panel_Height;   

        bool bqdzkzzl = false;
        private void skinButton1_Click(object sender, EventArgs e)
        {
            bqdzkzzl = true;
            qdzkzzl = true;
            flowbass.bnj = false;
            bzbzl = true;
            //StartTestZBZL();
            tzbzl = new Thread(threadzbzl);
            tzbzl.Start();
        }
        public bool bxz = false;
        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            bxz = chergxz.Checked;
            objwkccbass.brgxz = chergxz.Checked;
        }

        public void setLedWritezbzl(string ssh, string sxh, int iph)
        {
            if (bdhzbzl)
            {
                flowbass.LedWrite(sxh, ssh, iph);
            }
            else
            {
                flowbass.LedWrite(ssh, sxh, iph);
            }
            //bdhwkcc
        }

        public void setLedWritewkcc(string ssh, string sxh, int iph)
        {
            if (bdhzbzl)
            {
                flowbass.LedWritewkcc(sxh, ssh, iph);
            }
            else
            {
                flowbass.LedWritewkcc(ssh, sxh, iph);
            }
            //bdhwkcc
        }

        private void skinButton2_Click(object sender, EventArgs e)
        {
            chergxz.Checked = false;
        }

        private void TESTZBZL_Shown(object sender, EventArgs e)
        {
            float newx = (this.Width) / x;
            float newy = (this.Height) / y;
            setControls(newx, newy, this);
        }

        private SerialPort comzbzlDB = new SerialPort();//整备质量地磅
        public double m_fAIBrData_ZB = 0;//重量
        public bool openCOM(string sSet1, SerialPort commex)//打开串口
        {

            string[] szbzlCOM = new string[5];
            if (sSet1.Length > 0)
                szbzlCOM = sSet1.Split(':');
            //打开串口
            commex.PortName = szbzlCOM[0];
            commex.BaudRate = Convert.ToInt32(szbzlCOM[1]);

            commex.NewLine = "/r/n";
            commex.RtsEnable = true;//根据实际情况吧。 
            commex.ReadTimeout = 300;//读取数据延时，避免读取不全数据

            if (szbzlCOM[3] == "0")
                commex.Parity = Parity.None;
            else
                commex.Parity = Parity.Even;
            // ////添加事件注册  
            //  comm.DataReceived += comm_Data;
            try
            {
                commex.Open();
            }
            catch (Exception)
            {
                //lzj20200706    MessageBox.Show(string.Format("{0}\n请检查电脑的串口故障", ex.Message));
                return false;
            }
            return true;
        }
        public void initcom(string sSetCom)
        {
            openCOM(sSetCom, comzbzlDB);
            comzbzlDB.DataReceived += commzbzldb_DataReceived;
        }
        void commzbzldb_DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            Thread.Sleep(300);
            int n = comzbzlDB.BytesToRead;//先记录下来，避免某种原因，人为的原因，操作几次之间时间长，缓存不一致  
            byte[] buf = new byte[n];//声明一个临时数组存储当前来的串口数据  
            comzbzlDB.Read(buf, 0, n);//读取缓冲数据  

            if (buf.Length >= 12)
            {
                for (int i = 0; i + 12 <= buf.Length; i++)
                {
                    if (buf[i] == 0x02 && buf[i + 11] == 0x03)
                    {
                        double fqs = 0;
                        fqs = (buf[2] - 48) * 100000 + (buf[3] - 48) * 10000 + (buf[4] - 48) * 1000 + (buf[5] - 48) * 100 + (buf[6] - 48) * 10 + (buf[7] - 48); 
                        m_fAIBrData_ZB = fqs;

                    }
                }
            }
        }

        public bool byksd = false;
        private void skinButton3_Click(object sender, EventArgs e)
        {
            byksd = true;
        }

        public void updatezbzlpanding(int izbzljcz, ref string szbzlxz, ref int iblsxz, ref int iblxxz, ref int iczsxz, ref int iczxxz, ref int izbzlsx, ref int izbzlxx)
        {
            //string szbzlxz = "";
            double izbzl = flowbass.iCLZBZL;
            string scllx = flowbass.sCllx;
            string revert;

            //int izbzlsx = 0;
            //int izbzlxx = 0;
            //int iblsxz = 0;//比例上限值
            //int iblxxz = 0;//比例下限值
            //int iczsxz = 0;//差值上限值
            //int iczxxz = 0;//差值下限值
            int ipdbl = 0;//比例判定
            int ipdcz = 0;//差值判定
            if (scllx.Contains("中型") || scllx.Contains("重型") || scllx.Contains("挂"))
            {
                szbzlxz = "±3％或±500kg";
                if (izbzl * 3 / 100 >= 500)
                {
                    izbzlsx = (int)Math.Round(izbzl * 3 / 100 + izbzl);
                    izbzlxx = (int)Math.Round(izbzl - izbzl * 3 / 100);
                    iblsxz = izbzlsx;
                    iblxxz = izbzlxx;
                }
                else
                {
                    izbzlsx = (int)Math.Round(500 + izbzl);
                    izbzlxx = (int)Math.Round(izbzl - 500);
                    iczsxz = izbzlsx;
                    iczxxz = izbzlxx;
                }

            }
            else if (scllx.Contains("低速"))
            {
                szbzlxz = "±5％或±100kg";

                if (izbzl * 5 / 100 >= 100)
                {
                    izbzlsx = (int)Math.Round(izbzl * 5 / 100 + izbzl);
                    izbzlxx = (int)Math.Round(izbzl - izbzl * 5 / 100);
                    iblsxz = izbzlsx;
                    iblxxz = izbzlxx;
                }
                else
                {
                    izbzlsx = (int)Math.Round(100 + izbzl);
                    izbzlxx = (int)Math.Round(izbzl - 100);
                    iczsxz = izbzlsx;
                    iczxxz = izbzlxx;
                }
            }
            else if (scllx.Contains("轻型") || scllx.Contains("微型"))
            {
                szbzlxz = "±3％或±100kg";

                if (izbzl * 3 / 100 >= 100)
                {
                    izbzlsx = (int)Math.Round(izbzl * 3 / 100 + izbzl);
                    izbzlxx = (int)Math.Round(izbzl - izbzl * 3 / 100);
                    iblsxz = izbzlsx;
                    iblxxz = izbzlxx;
                }
                else
                {
                    izbzlsx = (int)Math.Round(100 + izbzl);
                    izbzlxx = (int)Math.Round(izbzl - 100);
                    iczsxz = izbzlsx;
                    iczxxz = izbzlxx;
                }
            }
            else
            {
                szbzlxz = "±3％或±500kg";
                if (izbzl * 3 / 100 >= 500)
                {
                    izbzlsx = (int)Math.Round(izbzl * 3 / 100 + izbzl);
                    izbzlxx = (int)Math.Round(izbzl - izbzl * 3 / 100);
                    iblsxz = izbzlsx;
                    iblxxz = izbzlxx;
                }
                else
                {
                    izbzlsx = (int)Math.Round(500 + izbzl);
                    izbzlxx = (int)Math.Round(izbzl - 500);
                    iczsxz = izbzlsx;
                    iczxxz = izbzlxx;
                }
            }

            if (scllx.Contains("摩托"))
            {
                szbzlxz = "±10kg";
                izbzlsx = (int)Math.Round(10 + izbzl);
                izbzlxx = (int)Math.Round(izbzl - 10);
                iczsxz = izbzlsx;
                iczxxz = izbzlxx;
            }
            ////增加进行分项目比例判定和差值判定--
            //            if (izbzljcz > iblsxz || izbzljcz < iblxxz)
            //            {
            //                ipdbl = 2;
            //            }
            //            else
            //            {
            //                ipdbl = 1;
            //            }
            //            if (scllx.Contains("摩托"))
            //            {
            //                ipdbl = 1;
            //            }
            //            if (izbzljcz > iczsxz || izbzljcz < iczxxz)
            //            {
            //                ipdcz = 2;
            //            }
            //            else
            //            {
            //                ipdcz = 1;
            //            }
            ////增加进行分项目比例判定和差值判定
            //            string szbzlpd;
            //            int izbzlpanding;
            //            if (izbzljcz > izbzlsx || izbzljcz < izbzlxx)
            //            {
            //                szbzlpd = "不合格";
            //                izbzlpanding = 2;
            //                flowbass.getbuhge(flowbass.sDetectID, "Z1");
            //            }
            //            else
            //            {

            //                flowbass.sethege(flowbass.sDetectID, "Z1");

            //                izbzlpanding = 1;
            //                szbzlpd = "合格";
            //            }
            //            string bz = "";
            //            bz = string.Format("差值:{0}kg、比例:{1}％",
            //                               (izbzljcz - izbzl) > 0 ? ("+" + (izbzljcz - izbzl).ToString()) : (izbzljcz - izbzl).ToString(),
            //                               ((izbzljcz - izbzl) / izbzl * 100) > 0 ? ("+" + ((izbzljcz - izbzl) / izbzl * 100).ToString("0.0")) : ((izbzljcz - izbzl) / izbzl * 100).ToString("0.0"));
            //            string szbzljieguo = "";
            //            if (bfbxs)
            //            {
            //                szbzljieguo = string.Format("整备质量(kg),{0},{1},{2},{3}", izbzljcz, szbzlxz, szbzlpd, bz);
            //            }
            //            else
            //            {
            //                szbzljieguo = string.Format("整备质量(kg),{0},{1}～{2},{3},{4}", izbzljcz, izbzlxx, izbzlsx, szbzlpd, bz);
            //            }
            //            if (flowbass.wbzl > 1)//有尾板质量时候增加备注
            //            {
            //                szbzljieguo = szbzljieguo + string.Format(",尾板质量为:{0}", flowbass.wbzl);
            //            }

            //            flowbass.AddData(flowbass.sDetectID, "DET_ZBZLJL", "Detects_SJA", izbzlpanding);
            //            flowbass.AddData(flowbass.sDetectID, "PD_ZBZL", "PD_AJ", szbzljieguo);


            //            flowbass.AddData(flowbass.sDetectID, "DET_ZBLZ_BLPD", "Detects_SJA", ipdbl);
            //            flowbass.AddData(flowbass.sDetectID, "DET_ZBLZ_CZPD", "Detects_SJA", ipdcz);

            //            model.安检联网.modelZ1 objbass = new model.安检联网.modelZ1();
            //            objbass.zbzl = izbzljcz.ToString();
            //            objbass.zbzlpd = izbzlpanding.ToString();
            //            if (flowbass.bnj)
            //            {

            //objbass.clzl      =
            //objbass.wbzl      =
            //objbass.qtbjzl    =
            //objbass.qtbjsm    =
            //objbass.bzzczbzl  =
            //objbass.zczbzlbfb = 
            //                revert = flowbass.objajlwbass.write(flowbass.objcarclass, objbass);

            //                if (!(revert.Length > 0 && revert[0].ToString() == "1"))
            //                {
            //                    flowbass.LedWrite("联网失败", revert, 1); Thread.Sleep(2000);
            //                }
            //            }
            //            flowbass.LedWrite("整备质量", izbzljcz.ToString(), 1);
            //            Thread.Sleep(xssj);
            //            flowbass.LedWrite("整备质量结果", szbzlpd, 1);
            //            Thread.Sleep(xssj);
            //            xianshineirong = szbzlpd;
            //            xianshi();
        }

        public void updatezbzlpanding_kczl(int izbzljcz, ref string szbzlxz, ref int iblsxz, ref int iblxxz, ref int iczsxz, ref int iczxxz, ref int izbzlsx, ref int izbzlxx)
        {
            //string szbzlxz = "";
            double izbzl = flowbass.iCLZBZL;
            string scllx = flowbass.sCllx;
            string revert;
            // bool bkc = false;
            //int izbzlsx = 0;
            //int izbzlxx = 0;
            ////int iblsxz = 0;//比例上限值
            ////int iblxxz = 0;//比例下限值
            //int iczsxz = 0;//差值上限值
            //int iczxxz = 0;//差值下限值
            //int ipdbl = 0;//比例判定
            //int ipdcz = 0;//差值判定
            if (scllx.Contains("中型") || scllx.Contains("重型") || scllx.Contains("挂"))
            {
                szbzlxz = "±10％或±500kg";
                if (izbzl * 10 / 100 >= 500)
                {
                    izbzlsx = (int)Math.Round(izbzl * 10 / 100 + izbzl);
                    izbzlxx = (int)Math.Round(izbzl - izbzl * 10 / 100);
                    iblsxz = izbzlsx;
                    iblxxz = izbzlxx;
                }
                else
                {
                    izbzlsx = (int)Math.Round(500 + izbzl);
                    izbzlxx = (int)Math.Round(izbzl - 500);
                    iczsxz = izbzlsx;
                    iczxxz = izbzlxx;
                }

            }
            else if (scllx.Contains("轻型") || scllx.Contains("微型"))
            {
                szbzlxz = "±10％或±200kg";

                if (izbzl * 10 / 100 >= 200)
                {
                    izbzlsx = (int)Math.Round(izbzl * 10 / 100 + izbzl);
                    izbzlxx = (int)Math.Round(izbzl - izbzl * 10 / 100);
                    iblsxz = izbzlsx;
                    iblxxz = izbzlxx;
                }
                else
                {
                    izbzlsx = (int)Math.Round(200 + izbzl);
                    izbzlxx = (int)Math.Round(izbzl - 200);
                    iczsxz = izbzlsx;
                    iczxxz = izbzlxx;
                }
                if (izbzlsx > 4500)
                {
                    izbzlsx = 4500;
                    iczsxz = izbzlsx;
                    iblsxz = izbzlsx;
                }
            }
            else
            {
                szbzlxz = "±10％或±200kg";

                if (izbzl * 10 / 100 >= 200)
                {
                    izbzlsx = (int)Math.Round(izbzl * 10 / 100 + izbzl);
                    izbzlxx = (int)Math.Round(izbzl - izbzl * 10 / 100);
                    iblsxz = izbzlsx;
                    iblxxz = izbzlxx;
                }
                else
                {
                    izbzlsx = (int)Math.Round(200 + izbzl);
                    izbzlxx = (int)Math.Round(izbzl - 200);
                    iczsxz = izbzlsx;
                    iczxxz = izbzlxx;
                }
                if (izbzlsx > 4500)
                {
                    izbzlsx = 4500;
                    iczsxz = izbzlsx;
                    iblsxz = izbzlsx;
                }
            }

            if (scllx.Contains("摩托"))
            {
                szbzlxz = "±10kg";
                izbzlsx = (int)Math.Round(10 + izbzl);
                izbzlxx = (int)Math.Round(izbzl - 10);
                iczsxz = izbzlsx;
                iczxxz = izbzlxx;
            }


            //izbzlpanding = 1;
            //zbzlpd = "1";
        }

        public void pandingzbzl(int izbzljcz, string szbzlxz, int iblsxz, int iblxxz, int iczsxz, int iczxxz, int izbzlsx, int izbzlxx, int izbkcbs = 1)
        {
            double izbzl = flowbass.iCLZBZL;
            string scllx = flowbass.sCllx;
            string revert;
            //int iczsxz = 0;//差值上限值
            //int iczxxz = 0;//差值下限值
            int ipdbl = 0;//比例判定
            int ipdcz = 0;//差值判定

            //增加进行分项目比例判定和差值判定--
            if (izbzljcz > iblsxz || izbzljcz < iblxxz)
            {
                ipdbl = 2;
            }
            else
            {
                ipdbl = 1;
            }
            if (scllx.Contains("摩托"))
            {
                ipdbl = 1;
            }
            if (izbzljcz > iczsxz || izbzljcz < iczxxz)
            {
                ipdcz = 2;
            }
            else
            {
                ipdcz = 1;
            }
            //增加进行分项目比例判定和差值判定
            string szbzlpd;
            int izbzlpanding;
            if (izbzljcz > izbzlsx || izbzljcz < izbzlxx)
            {
                szbzlpd = "不合格";
                izbzlpanding = 2;
                flowbass.getbuhge(flowbass.sDetectID, "Z1");
            }
            else
            {
                izbzlpanding = 1;
                szbzlpd = "合格";
            }
            string bz = "";
            bz = string.Format("差值:{0}kg、比例:{1}％",
                               (izbzljcz - izbzl) > 0 ? ("+" + (izbzljcz - izbzl).ToString()) : (izbzljcz - izbzl).ToString(),
                               ((izbzljcz - izbzl) / izbzl * 100) > 0 ? ("+" + ((izbzljcz - izbzl) / izbzl * 100).ToString("0.0")) : ((izbzljcz - izbzl) / izbzl * 100).ToString("0.0"));

            string szbzljieguo = "";
            if (bfbxs)
            {
                szbzljieguo = string.Format("{4}(kg),{0},{1},{2},{3}", izbzljcz, szbzlxz, szbzlpd, bz, izbkcbs == 1 ? "空车质量" : "整备质量");
            }
            else
            {
                szbzljieguo = string.Format("{5}(kg),{0},{1}～{2},{3},{4}", izbzljcz, izbzlxx, izbzlsx, szbzlpd, bz, izbkcbs == 1 ? "空车质量" : "整备质量");
            }

            if (flowbass.wbzl > 1)//有尾板质量时候增加备注
            {
                szbzljieguo = szbzljieguo + string.Format(",尾板质量为:{0}", flowbass.wbzl);
            }


            flowbass.AddData(flowbass.sDetectID, "DET_ZBZLJL", "Detects_SJA", izbzlpanding);
            flowbass.AddData(flowbass.sDetectID, "PD_ZBZL", "PD_AJ", szbzljieguo);
            flowbass.AddData(flowbass.sDetectID, "DET_ZBLZ_BLPD", "Detects_SJA", ipdbl);
            flowbass.AddData(flowbass.sDetectID, "DET_ZBLZ_CZPD", "Detects_SJA", ipdcz);

            //setLedWritezbzl(izbkcbs == 1 ? "空车质量" : "整备质量", izbzljcz.ToString(), 1);
            //Thread.Sleep(xssj);
            //setLedWritezbzl((izbkcbs == 1 ? "空车质量" : "整备质量") + "结果", szbzlpd, 1);
            //Thread.Sleep(xssj);
            setLedWritezbzl(izbkcbs == 1 ? "空车质量:" : "整备质量:", izbzljcz.ToString()+""+szbzlpd,1);
            Thread.Sleep(1500);
            flowbass.objajlwbass.sendpic(flowbass.izbzlqtongdao.ToString(), "0362", flowbass.objcarclass);
            flowbass.objajlwbass.sendpic(flowbass.izbzlhtongdao.ToString(), "0363", flowbass.objcarclass);
            Thread.Sleep(xssj);
            //    flowbass.objajlwbass.sendpic(flowbass.izbzlqtongdao.ToString(), "0362", flowbass.objcarclass);
            //    flowbass.objajlwbass.sendpic(flowbass.izbzlhtongdao.ToString(), "0363", flowbass.objcarclass);
            
            sneirongZBZL = szbzlpd;
            ZBZLshow();

            model.安检联网.modelZ1 objbass = new model.安检联网.modelZ1();
            objbass.zbzl = izbzljcz.ToString();
            objbass.zbzlpd = izbzlpanding.ToString();
            if (flowbass.bnj)
            {
                objbass.clzl = (izbzljcz + flowbass.wbzl).ToString();
                objbass.wbzl = (flowbass.wbzl > 1) ? flowbass.wbzl.ToString() : "";
                objbass.qtbjzl = "";
                objbass.qtbjsm = "";
                objbass.bzzczbzl = izbzl.ToString("0");
                //objbass.zczbzlbfb = Math.Round(Math.Abs(izbzljcz - izbzl) / izbzl * 100, 1).ToString();
                objbass.zczbzlbfb = ((izbzljcz - izbzl) / izbzl * 100).ToString("0.0");
                revert = flowbass.objajlwbass.write(flowbass.objcarclass, objbass);

                if (!(revert.Length > 0 && revert[0].ToString() == "1"))
                {
                    flowbass.LedWrite("联网失败", revert, 1); Thread.Sleep(2000);
                }
                flowbass.getProcessfinish(flowbass.sDetectID, "Z1");
                flowbass.UpdateLoginRecord(DateTime.Now.ToString(), "整备质量结束", flowbass.sDetectID);
                revert = flowbass.objajlwbass.SendJYXMKSSJ("Z1", "结束", flowbass.gwjysbbhzbzl, flowbass.izbzlhtongdao.ToString(), flowbass.objcarclass);
                if (!(revert.Length > 0 && revert[0].ToString() == "1"))
                {
                    if (flowbass.bnj)
                    {
                        setLedWritezbzl("联网失败", revert, 1); Thread.Sleep(2000);
                    }
                }
            }

        }
    }
}
